import { watchEffect } from "vue";
import { mySchoolRule } from "../options/base";
import { mySchoolStore } from '../store/index'
import { goToPage, showModal } from "./utils";

export function hideTabBarAutoShow():Promise<Function>{
    return new Promise(resolve=>{
        uni.hideTabBar();
        const state=mySchoolStore();
        resolve(()=>{
            uni.showTabBar()
        });
    })

}


export function homeMenuToPage({
    menu_status,
    nav_path,
    _id,
}: {
    menu_status: boolean;
    nav_path: string;
    _id:string
},
args:string|undefined=''        //必须是&开头
){
    if (!menu_status) {
        return showModal({
            title: `提示`,
            showCancel: false,
            content: `暂未开放请期待`
        });
    }
    if(nav_path.includes(`?`)){
        // 如果未包含ID 那么我们就添加id参数
        if(!/(\?id=)|(\&id=)/.test(nav_path)){
            nav_path=nav_path+`&id=${_id}${args}`
        }else{
            nav_path=nav_path+`${args}`
        }
    }else{
        nav_path=nav_path+`?id=${_id}${args}`
    }
    goToPage({
        path: nav_path,
        navType: `push`
    })
}